#ifndef IMGPRCMAINWINDOW_H
#define IMGPRCMAINWINDOW_H

#include <QMainWindow>
#include "ui_ImgPrcMainWindow.h"
#include "ThresholdDialog.h"
#include "HistogramDialog.h"
#include "FilterDialog.h"
#include "GrayscaleReconstructDialog.h"
// #include "AlgebraicOperationDialog.h"
#include "MorphologyDialog.h"
#include "Work.h"
#include "AbstractTool.h"
#include "exceptions.hpp"
#include <QMessageBox>


class ImgPrcMainWindow : public QMainWindow
{

	Q_OBJECT

private:

	Ui::mainWindow ui;
	ThresholdDialog * _pThresholdDialog;
	HistogramDialog * _pHistogramDialog;
	FilterDialog * _pFilterDialog;
	// AlgebraicOperationDialog * _pAlgebraicDialog;
	MorphologyDialog * _pMorphologyDialog;
	GrayscaleReconstructDialog * _pGrayscaleReconstructDialog;
	vector< Ptr< Work > > _works;
	int _curWorkIndex;
	AbstractTool * _curTool;

	void _initializeToolBox ();

	// virtual void keyPressEvent (QKeyEvent * event);
	// virtual void keyReleaseEvent (QKeyEvent * event);

public:

	ImgPrcMainWindow (QWidget *parent = 0, Qt::WFlags flags = 0);

public slots:

	// Menu Action Slots
	void handleOpenAction ();
	void handleSaveAction ();
	void handlePlaceAction ();

	void handleThresholdAction ();
	void handleAlgebraicAction ();

	void handleInterpolateLinearAction ();
	void handleInterpolateNeighborAction ();

	void handleViewHistogram ();
	void handleQuickMaskModeToggled (bool isChecked);

	void handleLinearFilterAction ();
	void handleMiddleFilterAction ();
	void handleGradientSobelAction ();
	void handleGradientPrewittAction ();
	void handleGradientRobertAction ();

	void handleMorphologyAction ();
	void handleDistanceTransformAction ();
	void handleSkeletonAction();
	void handleWTTAction ();
	void handleBTTAction ();
	void handleGrayscaleReconstructAction ();

	void handleWaterShedAction ();

	void switchDoc (int index);
	void closeDoc (int index);
	void toolTriggered (AbstractTool * pTool);

signals:

	// void globalKeyPressed (Ptr< Work > pWork, QKeyEvent * event);
	// void globalKeyReleased (Ptr< Work > pWork, QKeyEvent * event);

};

#endif // IMGPRCMAINWINDOW_H
